:root {
    /* 尺寸变量 */
    --sidebar-primary-width: 80px;
    --sidebar-secondary-width: 160px;
    --header-height: 52px;
    --brand-height: 50px;

    /* 主色调 - 简洁大气 */
    --primary-color: #3b82f6;
    --primary-light: #60a5fa;

    /* 深色主题 - 侧边栏和菜单 */
    --sidebar-bg: #0f172a;
    --sidebar-item-hover: rgba(255, 255, 255, 0.08);
    --sidebar-item-active: rgba(59, 130, 246, 0.2);
    --sidebar-border: rgba(255, 255, 255, 0.1);

    /* 菜单文字颜色 */
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-text-active: #ffffff;

    /* 中性色 */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-600: #475569;

    /* 功能色 */
    --error-color: #ef4444;

    /* 背景颜色 */
    --header-bg: var(--white);
    --content-bg: linear-gradient(135deg, var(--gray-50), var(--gray-100));

    /* 文字颜色 */
    --text-primary: #0f172a;
    --text-secondary: var(--gray-600);
    --text-tertiary: var(--gray-400);

    /* 边框颜色 */
    --border-light: #e2e8f0;
    --border-medium: var(--gray-300);

    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 字体设置 */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 主应用容器 */
.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* ===== 左侧边栏 ===== */
.sidebar-container {
    width: calc(var(--sidebar-primary-width) + var(--sidebar-secondary-width));
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

/* 品牌标识区域优化 */
.brand-container {
    height: var(--brand-height);
    background: var(--sidebar-bg);
    color: var(--sidebar-text-active);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0 16px;
}

.brand-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-content .brand-icon {
    font-size: 20px;
    color: var(--primary-light);
    padding: 6px;
    border-radius: 6px;
}

.brand-text {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    letter-spacing: 0;
}

/* 菜单容器 */
.menu-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 一级菜单样式优化 - 图标和文字水平排列 */
.primary-menu {
    width: var(--sidebar-primary-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
}

.primary-menu-items {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 8px;
}

.primary-menu-item {
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: left;
    border-left: 2px solid transparent;
    margin: 2px 0;
    border-radius: 0 6px 6px 0;
    gap: 8px;
}

.primary-menu-item:hover {
    background: var(--sidebar-item-hover);
    transform: translateX(1px);
}

.primary-menu-item.active {
    background: var(--sidebar-item-active);
    border-left-color: var(--primary-color);
}

.primary-menu-item .menu-icon {
    font-size: 14px;
    text-align: center;
    color: var(--sidebar-text);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.primary-menu-item:hover .menu-icon {
    color: var(--sidebar-text-hover);
}

.primary-menu-item.active .menu-icon {
    color: var(--sidebar-text-active);
}

.primary-menu-item .menu-label {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--sidebar-text);
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.primary-menu-item:hover .menu-label {
    color: var(--sidebar-text-hover);
}

.primary-menu-item.active .menu-label {
    color: var(--sidebar-text-active);
    font-weight: 600;
}

/* 二级菜单样式优化 */
.secondary-menu {
    width: var(--sidebar-secondary-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--sidebar-border);
}

.secondary-menu-items {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 8px;
}

.secondary-menu-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 2px solid transparent;
    color: var(--sidebar-text);
    margin: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    background: transparent;
}

.secondary-menu-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-hover);
    transform: translateX(1px);
}

.secondary-menu-item.active {
    background: var(--sidebar-item-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--primary-color);
}

.secondary-menu-item.active .folder-icon,
.secondary-menu-item.active .chevron-icon {
    color: var(--primary-color);
}

.secondary-menu-item .folder-icon {
    font-size: 12px;
    margin-right: 8px;
    width: 14px;
    text-align: center;
    color: var(--sidebar-text);
    transition: all 0.2s ease;
}

.secondary-menu-item:hover .folder-icon {
    color: var(--primary-color);
}

.secondary-menu-item .item-label {
    flex: 1;
    font-weight: 400;
    transition: all 0.2s ease;
}

.secondary-menu-item:hover .item-label {
    font-weight: 500;
}

.secondary-menu-item .chevron-icon {
    font-size: 10px;
    color: var(--sidebar-text);
    transition: all 0.2s ease;
    margin-left: 4px;
}

.secondary-menu-item:hover .chevron-icon {
    color: #3b82f6;
}

/* 浮动菜单样式 */
.floating-menu {
    position: fixed;
    z-index: 10000;
    display: none;
    background: var(--sidebar-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 12px;
    max-width: 90vw;
    border: 1px solid var(--sidebar-border);
    transition: all 0.2s ease;
}

/* 三级菜单标题区域 */
.floating-menu-header {
    margin-bottom: 4px;
    color: var(--sidebar-text-active);
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 6px;
}

/* 浮动菜单的标题文本 */
.floating-menu-header-text {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
}

/* 直接访问菜单项容器 */
.floating-menu-header-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

/* 标题区域中的菜单项（如销售设置） */
.floating-menu-header-item {
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--primary-color);
    font-size: 11px;
    border-radius: 3px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    font-weight: 500;
}

.floating-menu-header-item:hover {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-light);
}

.floating-menu-columns {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.floating-menu-column {
    flex: 1;
    min-width: 0;
}

.floating-menu-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--sidebar-text);
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.floating-menu-item {
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--sidebar-text);
    font-size: 12px;
    border-radius: 4px;
    margin: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.floating-menu-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-hover);
    transform: translateX(2px);
}

/* ===== 右侧内容区域 ===== */
.content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
    background: var(--content-bg);
}

/* 顶部导航栏 */
.content-header {
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 12px;
    box-shadow: var(--shadow-sm);
}

.content-header-left {
    position: relative;
    min-width: 0;
    flex: 1;
    margin: 0;
}

.content-header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
}

/* 工具栏按钮样式 - 统一按钮样式 */
.toolbar-button {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 6px;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toolbar-button:hover {
    color: var(--primary-color);
    background: var(--gray-100);
}

/* 按钮图标特殊样式 */
.toolbar-button.large-icon {
    font-size: 18px;
}

/* 用户下拉菜单 */
.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 4px 10px;
    color: var(--text-secondary);
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    cursor: pointer;
    font-weight: 500;
    min-width: 120px;
}

.user-dropdown-btn:hover {
    background: var(--gray-50);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.user-dropdown-btn .user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.user-dropdown-btn .dropdown-arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
    color: var(--text-tertiary);
}

.user-dropdown-btn.show .dropdown-arrow {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.user-dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    padding: 4px;
    min-width: 120px;
    margin-top: 4px;
    display: none;
    z-index: 1000;
}

.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-item {
    padding: 8px 10px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    font-weight: 400;
}

.user-dropdown-item:hover {
    background: var(--gray-50);
    color: var(--primary-color);
}

.user-dropdown-item .item-icon {
    width: 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

.user-dropdown-item:hover .item-icon {
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* ===== 标签栏样式 ===== */
.tab-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: transparent;
    margin: 0;
    padding: 0 36px;
    gap: 0;
    box-sizing: border-box;
}

.scroll-viewport {
    flex: 1;
    overflow: hidden;
    background: transparent;
    transition: none;
}

.tab-items {
    display: flex;
    transition: transform 0.3s ease;
    padding: 0;
    margin: 0;
    list-style: none;
    white-space: nowrap;
    gap: 0;
}

.tab-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    position: relative;
    flex-shrink: 0;
    white-space: nowrap;
    font-weight: 400;
    /* 拖动相关样式 */
    touch-action: none;
    -webkit-user-select: none; /* Safari 3-15 */
    -moz-user-select: none; /* Firefox 2-40 */
    -ms-user-select: none; /* IE 10-11 */
    user-select: none;
}

/* 拖动中的标签样式 */
.tab-item.dragging {
    cursor: grabbing;
}

/* 拖动中的标签样式 */
.tab-item.dragging {
    opacity: 0.7;
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: grabbing;
    z-index: 1000;
    background: var(--white);
}

/* 拖动时的占位符样式 */
.tab-item.placeholder {
    background: var(--border-light);
    border-radius: 4px;
    height: 30px;
    margin: 2px 0;
    pointer-events: none;
    cursor: default;
    min-width: 80px;
    opacity: 0.6;
}

/* 可放置区域高亮 */
.tab-item.drag-over {
    border-bottom-color: var(--primary-color);
}

.tab-item:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-medium);
    background: var(--gray-50);
}

.tab-item.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 500;
}

.tab-item.loading {
    position: relative;
    z-index: 100;
}

.tab-item.loading::after {
    content: '⏳ 加载中...';
    position: absolute;
    right: -8px;
    top: 100%;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--gray-100);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tab-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.tab-close-button:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

.tab-item[data-tab-id='dashboard'] .tab-close-button {
    display: none !important;
}

#scrollLeftButton {
    left: 4px;
}

#scrollRightButton {
    right: 4px;
}

.scroll-button {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: var(--white);
    border: 0;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
}

.scroll-button:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.scroll-button.hidden {
    opacity: 0;
    visibility: hidden;
    width: 0;
    padding: 0;
    pointer-events: none;
}

.scroll-button:hover {
    color: var(--primary-color);
    background: var(--gray-100);
}

.scroll-button:disabled {
    color: var(--border-medium);
    cursor: not-allowed;
}

/* 标签内容区域 */
.content-panels {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.tab-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.tab-panel.active {
    opacity: 1;
    visibility: visible;
}

.tab-panel iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== 右键菜单样式 ===== */
.context-menu {
    position: fixed;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    z-index: 10000;
    display: none;
    min-width: 140px;
    padding: 4px;
    animation: menuFadeIn 0.15s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.context-menu-item {
    padding: 8px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 1px 0;
    font-weight: 400;
}

.context-menu-item:hover {
    background: var(--gray-50);
    color: var(--primary-color);
}

.context-menu-item .menu-icon {
    width: 14px;
    text-align: center;
    font-size: 10px;
    color: var(--text-tertiary);
}

.context-menu-item:hover .menu-icon {
    color: var(--primary-color);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 3px 0;
}

.context-menu-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 主内容区域的浅色滚动条 */
.content-area ::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.content-area ::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

.content-area ::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}
